<!--编辑承建-->
<template>
    <div>
        <el-row>
            <el-col :span="18">
                <el-form :inline="true" :model="formB" class="demo-form-inline" >
                    <!--资质颁发单位-->
                    <el-form-item label="资质颁发单位">
                        <el-select v-model="formB.construct_award_unit">
                            <el-option :label="item.name" :value="item.id" v-for="item in BFMessage"></el-option>
                        </el-select>
                    </el-form-item>
                    <!--资质等级-->
                    <el-form :inline="true" :model="formB" class="demo-form-inline">
                        <el-form-item label="资质等级">
                            <el-select v-model="formB.construct_zizhi_level">
                                <el-option :label="item.name" :value="item.id" v-for="item in DJMessage"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <!--其他-->
                    <!--收费标准-->
                    <el-form-item label="收费标准">
                        <el-input v-model="formB.construct_charge_standard" placeholder="收费标准"></el-input>
                    </el-form-item>
                    <!--专业领域-->
                    <el-form-item label="专业领域">
                        <el-input v-model="formB.construct_major_field" placeholder="专业领域"></el-input>
                    </el-form-item>
                    <!--技术团队资源-->
                    <el-form-item label="技术团队资源">
                        <el-input v-model="formB.technology_team_resource" placeholder="技术团队资源"></el-input>
                    </el-form-item>
                    <!--主营业务-->
                    <el-form-item label="主营业务">
                        <el-input v-model="formB.construct_main_business" placeholder="主营业务"></el-input>
                    </el-form-item>
                </el-form>
                <!--业务区域-->
                <el-form :inline="true" :model="formB" class="demo-form-inline">
                    <el-form-item label="业务区域">
                        <span v-for="item in form.provinceOptions" style="margin:10px">{{item}}</span>
                    </el-form-item>
                    <el-button type="info" @click="openDialog('addArea')" style="margin-bottom:20px">设置区域</el-button>
                </el-form>
                <!--施工担保方式-->
                <el-form :inline="true" :model="formB" class="demo-form-inline">
                <el-form-item label="施工担保方式">
                        <el-checkbox-group v-model="formB.construct_assure_method">
                            <el-checkbox label="62">现金</el-checkbox>
                            <el-checkbox label="63">保函</el-checkbox>
                            <el-checkbox label="64">第三方</el-checkbox>
                            <el-checkbox label="65" >其他</el-checkbox>
                        </el-checkbox-group>
                </el-form-item>
                </el-form>
                <!--特殊能力-->
                <el-form :inline="true" :model="formB" class="demo-form-inline">
                    <el-form-item label="特殊能力">
                        <template>
                            <el-checkbox-group v-model="formB.special_ability">
                                <el-checkbox :label="item.id" v-for="item in specialBox">{{item.name}}</el-checkbox>
                            </el-checkbox-group>
                        </template>
                    </el-form-item>
                </el-form>
                <h3>关键人物</h3>
                <el-form :inline="true" :model="formB" class="demo-form-inline" v-for="(item,index) in arr" style="padding-left: 80px">
                    <el-form-item >
                        <el-select v-model="formB.construct_relation_person[index]" placeholder="请选择">
                            <el-option
                                    v-for="data in JlMessage"
                                    :label="data.personal_name"
                                    :value="data.personal_id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="职务">
                        <el-select v-model="formB.construct_relation_position[index]" placeholder="请选择">
                            <el-option
                                    v-for="data in Duty"
                                    :key="data.id"
                                    :label="data.name"
                                    :value="data.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-button type="text" @click="delMan(index)">移除</el-button>
                </el-form>
                <el-button type="info" @click="addMan" style="margin-left: 80px">添加人物</el-button>
            </el-col>
            <el-col :span="1">
                <hr style="height:200px;width: 1px">
            </el-col>
            <el-col :span="5"><div >
                <h2>评价星级</h2>
                <el-form :inline="true" :model="formB" class="demo-form-inline">
                    <el-form-item>
                        <el-select v-model="formB.construct_evaluate_star" placeholder="评价星级">
                            <el-option label="一星" value="一星"></el-option>
                            <el-option label="二星" value="二星"></el-option>
                            <el-option label="三星" value="三星"></el-option>
                            <el-option label="四星" value="四星"></el-option>
                            <el-option label="五星" value="五星"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div></el-col>
        </el-row>
        <!--省份选项-->
        <el-dialog title="售后网络覆盖区域" :visible.sync="dialog.addArea.open" v-if="dialog.addArea.open" :modal="false" top="65%" size="small">
            <template>
                <el-checkbox-group v-model="formB.construct_business_area">

                    <el-checkbox :label="item.district_id" v-for="item in quyuBox" style="margin: 10px">{{item.district}}</el-checkbox>
                </el-checkbox-group>
                <el-button type="primary" size="small" @click=" addProvince('addArea')">确定</el-button>
            </template>
        </el-dialog>
        <div style="width:100px;margin-left:80%">
            <el-button type="warning" @click="sendFormD">保存能力</el-button>
        </div>
    </div>
    <!--<button @click="">保存</button>-->
</template>
<script>
    import Bus from '@/config/bus.js'
    import _http from '@/components/common/http.vue'
    import _param from '@/components/common/param.vue'
    export default {
        data() {
            return {
                apiPort:{
                    DutyApi:'diction/getEnterpriseType',
                    customerManager:'ctm/v1/getPersonal',
//                    资质类别列表
                    aptitudeList:'diction/getEnterpriseType',
//                    资质颁发单位列表
                    aptitudeawardList:'diction/getEnterpriseType',
//                    资质等级列表
                    aptitudelevelList:'diction/getEnterpriseType',
//                    区域字典
                    quyuApi:'diction/getProince',
//                    承建特殊能力
                    specialAble:'diction/getEnterpriseType'
                },
                formB:{
                    construct_zizhi_level:'',
                    construct_award_unit:'',
                    construct_charge_standard:'',
                    construct_major_field:'',
                    technology_team_resource:'',
                    construct_main_business:'',
                    construct_business_area:[],
                    construct_assure_method:[],
                    special_ability:[],
                    construct_evaluate_star:'',
                    construct_relation_person:[],
                    construct_relation_position:[]
                },
                position:'left',
//                关键人物信息存储
                entrepot:[{name:'',status:''}],
                keyManmessage:[{
                    man:[
                        {
                            value: '选项4',
                            label: '人物一'
                        }, {
                            value: '选项5',
                            label: '人物二'
                        }
                    ],
                    duty:[
                        {
                            value: '选项4',
                            label: '人物三'
                        },
                        {
                            value: '选项5',
                            label: '人物四'
                        }
                    ]}
                ],
                dialog:{
                    addShebei:{
                        open:false
                    },
                    addArea:{
                        open:false
                    }
                },
                checkList: [],
                form:{
                    provinceOptions:[],
                    provinceList:[],
//                    资质类别列表
                    aptitudeList:'',
                    aptitudeId:'',
//                    资质颁发单位列表
                    aptitudeawardList:'',
                    aptitudeawardId:'',
//                    资质等级列表
                    aptitudelevelList:'',
                    aptitudelevelId:''
                },
                radio:'1',
                information:{
                    classes:'综合',
                    issued:'住建部',
                    grade:'甲级',
                    charge:'100000元每案',
                    professField:'土地规划，环保设计',
                    keyMan1:'俞兆洪-总裁/CEO-18058715658',
                    keyMan2:'吴高翔-销售-18058715658'
                },
                LBMessage:'',
                BFMessage:'',
                DJMessage:'',
                quyuBox:[],
                specialBox:'',
                JlMessage:'',
                Duty:'',
                arr:[],
                userid:''
            }
        },
        mounted(){
            var that = this
         this.userid = localStorage.getItem('userId')
          this.getDicdata()

        },
        beforeDestroy(){
            Bus.$off("CommitFlag")
        },
        methods:{
//            传递参数的方法
            sendFormD(){
                var that = this
                if(this.formB.construct_relation_person.length==this.formB.construct_relation_position.length){
                    setTimeout(function(){
                        Bus.$emit("submitFormB",that.formB)
                        that.$message({
                            message: '保存成功',
                            type: 'success'
                        });
                    },200)
                }else{
                    that.$message({
                        message: '补全关系人物',
                        type: 'warning'
                    });
                }
            },
            getDicdata(){
                var that = this
                var paramSh={code:"cj_zzbfdw",userid:that.userid}
                var paramsSh = that.querystring.stringify(paramSh)
                _http.axiosRequest(that,that.apiPort.aptitudeawardList,paramsSh,(res)=>{
                    that.BFMessage=res.data.data
                console.log(that.BFMessage)
                })

                //资质等级
                var paramSh={code:"cjqyzz",userid:that.userid}
                var paramsSh = that.querystring.stringify(paramSh)
                _http.axiosRequest(that,that.apiPort.aptitudelevelList,paramsSh,(res)=>{
                    that.DJMessage=res.data.data
            })
                //            客户经理接口
                var paramsComZ = that.querystring.stringify({userid:that.userid})
                _http.axiosRequest(that,that.apiPort.customerManager,paramsComZ,(res)=>{
                    that.JlMessage=res.data
                console.log('客户经理')
                console.log(that.JlMessage)
            })
                var paramComZ={code:"zhiwei",userid:that.userid}
                var paramsComZ = that.querystring.stringify(paramComZ)
                _http.axiosRequest(that,that.apiPort.DutyApi,paramsComZ,(res)=>{
                    that.Duty=res.data.data
            })
//                获取区域字典
                var paramsComZ = that.querystring.stringify({userid:that.userid})
                _http.axiosRequest(that,that.apiPort.quyuApi,paramsComZ,(res)=>{
                    console.log("quyu")
                console.log(res.data.data)
                that.quyuBox=res.data.data
            })
                var paramSp={code:"cjtsnl",userid:that.userid}
                var paramsSp = that.querystring.stringify(paramSp)
//                获取特殊能力字典
                _http.axiosRequest(that,that.apiPort.specialAble,paramsSp,(res)=>{
                    console.log('特殊能力')
                console.log(res.data.data)
                that.specialBox=res.data.data
            })
            },
            addProvince(addField){
                this.form.provinceOptions=[]
                var fie = this.quyuBox
                var che = this.formB.construct_business_area
                for(var i in che){
                    for(var j in fie){
                        if(fie[j].district_id==che[i]){
                            this.form.provinceOptions.push(fie[j].district)
                        }
                    }
                }

//                this.form.provinceOptions=this.formB.construct_business_area

                this.dialog[addField].open = false
            },
            openDialog(dialog){
                this.dialog[dialog].open = true
            },
            addMan(){
                this.arr.push(1)
            },
            delMan(index){
                this.arr.splice(index,1)
                this.formB.construct_relation_person.splice(index,1)
                this.formB.construct_relation_position.splice(index,1)
            },
        }
    }
</script>